package com.hqyj.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * @author chen3
 * @description MD5散列算法加密
 * @date 2021-08-10 15:46
 */
public class MD5Util {
    /**
     * @author chen3
     * @date 2021-08-10 15:48
     * @params  password 原文密码 salt 盐
     * @return String 暗文密码
     * @description md5加密
     */
    public static String md5Hash(String password,String salt){
        //对盐 salt 做类型转换
        ByteSource saltByts = ByteSource.Util.bytes(salt);
        SimpleHash simpleHash = new SimpleHash("MD5", password, saltByts, 1024);
        return simpleHash.toString();
    }

    public static void main(String[] args) {
        String password = "123";
        String salt = "zxf";
        System.out.println(md5Hash(password,salt));
//        Date date = new Date();
//        System.out.println(date);
//        SimpleDateFormat dft = new SimpleDateFormat("yyyyMMddhhmmss");
//        System.out.println(dft.format(date));
    }
}
